package com.my.srpingboot.starter.test.config;

import com.my.srpingboot.starter.test.HelloProperties;
import com.my.srpingboot.starter.test.service.HelloService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zp
 * @version 1.0
 * @description: TODO
 * @date 2022/9/24 16:44
 */
@Configuration //设置这是一个配置类
@EnableConfigurationProperties(HelloProperties.class) //绑定配置类 自动注入到容器当中
public class HellServiceAutoConfigure {

    @ConditionalOnMissingBean(HelloService.class) //自动配置类的生效条件 当ioc容器当中不存在HellService类的时候加载生效
    @Bean
    public HelloService helloService(){
        return new HelloService();
    }
}
